<template>
	<view class="container">
		<uni-section :title="`食物评论列表展示`" sub-title="" type="line">
			<uni-list>
				<uni-list-item v-for="(item, index) in commentList" :key="index" :title="item.comment" note="" clickable 
				@click="openCommentdetail(item.comment)"></uni-list-item>
			</uni-list>
		</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				commentList: []
			}
		},
		methods: {
			openCommentdetail(comment) {
				uni.navigateTo({
					url:`/pages/comment/commentdetail/commentdetail?comment=${comment}`
				})
			}
		},
		onLoad ()  {
			uni.request({
				url: 'http://localhost:8090/foodapp/comment/list',
				method: 'POST',
				success: res => {
					this.commentList = res.data.list;
				}
			});
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
